#!/bin/sh
# Job yaml can send below ENVIRONMENT VARIABLES to me
# - bp_memmap
# - bp1_memmap
# - bp2_memmap
# - bp3_memmap
# - bp4_memmap
# - bp_disable_mtrr_trim
# - bp_idle
# - bp_maxcpus
# - bp_intel_iommu
# - accept_memory
# - acpi
# - acpi_apic_instance
# - acpi_backlight
# - acpi.debug_layer
# - acpi.debug_level
# - acpi_enforce_resources
# - acpi_irq_isa
# - acpi_irq_pci
# - acpi_mask_gpe
# - acpi_osi
# - acpi_os_name
# - acpi_rsdp
# - acpi_sci
# - acpi_sleep
# - agp
# - alignment
# - align_va_addr
# - amd_iommu
# - amd_iommu_dump
# - amd_iommu_intr
# - amd_prefcore
# - amd_pstate
# - amijoy.map
# - analog.map
# - apc
# - apic
# - apic_extnmi
# - apm
# - apparmor
# - arcrimi
# - ataflop
# - atarimouse
# - atkbd.extra
# - atkbd.reset
# - atkbd.scroll
# - atkbd.set
# - atkbd.softraw
# - atkbd.softrepeat
# - audit
# - audit_backlog_limit
# - autoconf
# - bau
# - baycom_epp
# - baycom_par
# - baycom_ser_fdx
# - baycom_ser_hdx
# - bdev_allow_write_mounted
# - blkdevparts
# - boot_delay
# - bttv.card
# - bttv.pll
# - bttv.radio
# - bttv.tuner
# - bulk_remove
# - c101
# - cachesize
# - ca_keys
# - carrier_timeout
# - cca
# - cgroup_disable
# - cgroup_favordynmods
# - cgroup.memory
# - cgroup_no_v1
# - checkreqprot
# - cio_ignore
# - clearcpuid
# - clock
# - clocksource
# - clocksource.arm_arch_timer.evtstrm
# - clocksource.verify_n_cpus
# - clocksource-wdtest.holdoff
# - cma
# - cma_pernuma
# - cmo_free_hint
# - coherent_pool
# - com20020
# - com90io
# - com90xx
# - con3215_drop
# - condev
# - conmode
# - console
# - consoleblank
# - console_msg_format
# - coredump_filter
# - cpcihp_generic
# - cpufreq.default_governor
# - cpufreq.off
# - cpuhp.parallel
# - cpuidle.governor
# - cpuidle.off
# - cpu_init_udelay
# - crashkernel
# - cs89x0_dma
# - cs89x0_media
# - csdlock_debug
# - dasd
# - debugfs
# - debug_guardpage_minorder
# - debug_locks_verbose
# - debug_pagealloc
# - default_hugepagesz
# - deferred_probe_timeout
# - dell_smm_hwmon.fan_max
# - dell_smm_hwmon.fan_mult
# - dell_smm_hwmon.force
# - dell_smm_hwmon.ignore_dmi
# - dell_smm_hwmon.power_status
# - dell_smm_hwmon.restricted
# - dfltcc
# - dhash_entries
# - disable
# - disable_ipv6
# - dma_debug
# - dma_debug_driver
# - dma_debug_entries
# - driver_async_probe
# - drm.edid_firmware
# - dscc4.setup
# - dt_cpu_ftrs
# - earlycon
# - earlyprintk
# - edac_report
# - edd
# - efi
# - efivar_ssdt
# - eisa_irq_edge
# - ekgdboc
# - elanfreq
# - elfcorehdr
# - enforcing
# - ether
# - evm
# - fail_make_request
# - fail_page_alloc
# - failslab
# - fail_usercopy
# - fb_tunnels
# - floppy
# - fred
# - ftrace
# - ftrace_filter
# - ftrace_graph_filter
# - ftrace_graph_max_depth
# - ftrace_graph_notrace
# - ftrace_notrace
# - fw_devlink
# - fw_devlink.strict
# - gamma
# - gart_fix_e820
# - gather_data_sampling
# - gcov_persist
# - grcan.enable0
# - grcan.enable1
# - grcan.rxsize
# - grcan.select
# - grcan.txsize
# - hardened_usercopy
# - hardlockup_all_cpu_backtrace
# - hashdist
# - hd
# - hibernate
# - hibernate.compressor
# - highmem
# - highres
# - hostname
# - hpet
# - hpet_mmap
# - hugepages
# - hugepagesz
# - hugetlb_cma
# - hugetlb_free_vmemmap
# - hung_task_panic
# - hvc_iucv
# - hvc_iucv_allow
# - i2c_bus
# - i2c_touchscreen_props
# - i810
# - i915.invert_brightness
# - ia32_emulation
# - icn
# - idle
# - idxd.sva
# - idxd.tc_override
# - ieee754
# - ihash_entries
# - ima.ahash_bufsize
# - ima.ahash_minsize
# - ima_appraise
# - ima_hash
# - ima_policy
# - ima_template
# - ima_template_fmt
# - init
# - initcall_blacklist
# - init_on_alloc
# - init_on_free
# - init_pkru
# - initramfs_async
# - initrd
# - initrdmem
# - inport.irq
# - integrity_audit
# - intel_idle.max_cstate
# - intel_iommu
# - intel_pstate
# - intremap
# - io7
# - io_delay
# - iomem
# - iommu
# - iommu.forcedac
# - iommu.passthrough
# - iommu.strict
# - ip
# - ipe.enforce
# - ipe.success_audit
# - irqaffinity
# - irqchip.gicv2_force_probe
# - irqchip.gicv3_nolpi
# - irqchip.gicv3_pseudo_nmi
# - isapnp
# - isolcpus
# - iucv
# - js
# - kernelcore
# - kgdbdbgp
# - kgdboc
# - kgdboc_earlycon
# - kmac
# - kmemleak
# - kprobe_event
# - kpti
# - kunit.enable
# - kvm-amd.nested
# - kvm-amd.npt
# - kvm-arm.mode
# - kvm-arm.vgic_v3_common_trap
# - kvm-arm.vgic_v3_group0_trap
# - kvm-arm.vgic_v3_group1_trap
# - kvm-arm.vgic_v4_enable
# - kvm-arm.wfe_trap_policy
# - kvm-arm.wfi_trap_policy
# - kvm_cma_resv_ratio
# - kvm.eager_page_split
# - kvm.enable_virt_at_load
# - kvm.enable_vmware_backdoor
# - kvm.ignore_msrs
# - kvm-intel.emulate_invalid_guest_state
# - kvm-intel.ept
# - kvm-intel.flexpriority
# - kvm-intel.nested
# - kvm-intel.unrestricted_guest
# - kvm-intel.vmentry_l1d_flush
# - kvm-intel.vpid
# - kvm.nx_huge_pages
# - kvm.nx_huge_pages_recovery_period_ms
# - kvm.nx_huge_pages_recovery_ratio
# - l1d_flush
# - l1tf
# - l2cr
# - l3cr
# - lapic
# - libata.dma
# - libata.force
# - libata.ignore_hpa
# - load_ramdisk
# - lockd.nlm_grace_period
# - lockd.nlm_tcpport
# - lockd.nlm_timeout
# - lockd.nlm_udpport
# - lockdown
# - locktorture.acq_writer_lim
# - locktorture.bind_readers
# - locktorture.bind_writers
# - locktorture.call_rcu_chains
# - locktorture.long_hold
# - locktorture.nested_locks
# - locktorture.nreaders_stress
# - locktorture.nwriters_stress
# - locktorture.onoff_holdoff
# - locktorture.onoff_interval
# - locktorture.rt_boost
# - locktorture.rt_boost_factor
# - locktorture.shuffle_interval
# - locktorture.shutdown_secs
# - locktorture.stat_interval
# - locktorture.stutter
# - locktorture.torture_type
# - locktorture.verbose
# - locktorture.writer_fifo
# - log_buf_len
# - logibm.irq
# - loglevel
# - lp
# - lpj
# - lsm
# - machtype
# - maxcpus
# - max_loop
# - mce
# - md
# - mdacon
# - mds
# - mem
# - memblock
# - memchunk
# - mem_encrypt
# - memhp_default_state
# - memmap
# - memory_corruption_check
# - memory_corruption_check_period
# - memory_corruption_check_size
# - mem_sleep_default
# - memtest
# - mga
# - microcode.force_minrev
# - mini2440
# - mitigations
# - mminit_loglevel
# - mmio_stale_data
# - module.async_probe
# - module_blacklist
# - mousedev.tap_time
# - mousedev.xres
# - mousedev.yres
# - movablecore
# - MTD_Partition
# - mtdparts
# - MTD_Region
# - mtouchusb.raw_coordinates
# - mtrr
# - mtrr_chunk_size
# - mtrr_gran_size
# - mtrr_spare_reg_nr
# - multitce
# - n2
# - netdev
# - netpoll.carrier_timeout
# - nf_conntrack.acct
# - nfs4.layoutstats_timer
# - nfsaddrs
# - nfs.cache_getent
# - nfs.cache_getent_timeout
# - nfs.callback_nr_threads
# - nfs.callback_tcpport
# - nfs.delay_retrans
# - nfsd.inter_copy_offload_enable
# - nfsd.nfs4_disable_idmapping
# - nfsd.nfsd4_ssc_umount_timeout
# - nfs.enable_ino64
# - nfs.idmap_cache_timeout
# - nfs.max_session_cb_slots
# - nfs.max_session_slots
# - nfs.nfs4_disable_idmapping
# - nfs.nfs4_unique_id
# - nfs.recover_lost_locks
# - nfsroot
# - nfs.send_implementation_id
# - nmi_debug
# - nmi_watchdog
# - nohz
# - nohz_full
# - nopv
# - nr_cpus
# - nr_uarts
# - numa
# - numa_balancing
# - numa_cma
# - numa_zonelist_order
# - ohci1394_dma
# - olpc_ec_timeout
# - omap_mux
# - onenand.bdry
# - oops
# - page_alloc.shuffle
# - page_owner
# - page_poison
# - page_reporting.page_reporting_order
# - panic
# - panic_on_taint
# - panic_on_warn
# - panic_print
# - parkbd.mode
# - parkbd.port
# - parport
# - parport_init_mode
# - pata_legacy.all
# - pata_legacy.autospeed
# - pata_legacy.ht6560a
# - pata_legacy.ht6560b
# - pata_legacy.iordy_mask
# - pata_legacy.opti82c46x
# - pata_legacy.opti82c611a
# - pata_legacy.pio_mask
# - pata_legacy.probe_all
# - pata_legacy.probe_mask
# - pata_legacy.qdi
# - pata_legacy.winbond
# - pata_platform.pio_mask
# - pause_on_oops
# - pcbit
# - pci
# - pcie_aspm
# - pcie_pme
# - pcie_port_pm
# - pcie_ports
# - pcmv
# - pdcchassis
# - percpu_alloc
# - pirq
# - plip
# - pmtmr
# - pmu_override
# - pnpacpi
# - pnpbios
# - pnp.debug
# - pnp_reserve_dma
# - pnp_reserve_io
# - pnp_reserve_irq
# - pnp_reserve_mem
# - ports
# - possible_cpus
# - powersave
# - ppc_tm
# - preempt
# - printk.always_kmsg_dump
# - printk.console_no_auto_verbose
# - printk.devkmsg
# - printk.time
# - processor.max_cstate
# - proc_mem.force_override
# - profile
# - prompt_ramdisk
# - prot_virt
# - psi
# - psmouse.proto
# - psmouse.rate
# - psmouse.resetafter
# - psmouse.resolution
# - psmouse.smartscroll
# - pstore.backend
# - pti
# - pty.legacy_count
# - r128
# - radix_hcall_invalidate
# - raid
# - ramdisk_size
# - ramdisk_start
# - randomize_kstack_offset
# - random.trust_bootloader
# - random.trust_cpu
# - ras
# - rcupdate.rcu_cpu_stall_cputime
# - rcupdate.rcu_cpu_stall_ftrace_dump
# - rcupdate.rcu_cpu_stall_notifiers
# - rcupdate.rcu_cpu_stall_suppress
# - rcupdate.rcu_cpu_stall_suppress_at_boot
# - rcupdate.rcu_cpu_stall_timeout
# - rcupdate.rcu_exp_cpu_stall_timeout
# - rcupdate.rcu_expedited
# - rcupdate.rcu_exp_stall_task_details
# - rcupdate.rcu_normal
# - rcupdate.rcu_normal_after_boot
# - rcupdate.rcu_self_test
# - rcupdate.rcu_task_collapse_lim
# - rcupdate.rcu_task_contend_lim
# - rcupdate.rcu_task_enqueue_lim
# - rcupdate.rcu_task_ipi_delay
# - rcupdate.rcu_task_lazy_lim
# - rcupdate.rcu_tasks_lazy_ms
# - rcupdate.rcu_task_stall_info
# - rcupdate.rcu_task_stall_info_mult
# - rcupdate.rcu_task_stall_timeout
# - rcupdate.rcu_tasks_trace_lazy_ms
# - rcuscale.gp_async
# - rcuscale.gp_async_max
# - rcuscale.gp_exp
# - rcuscale.holdoff
# - rcuscale.kfree_alloc_num
# - rcuscale.kfree_by_call_rcu
# - rcuscale.kfree_loops
# - rcuscale.kfree_mult
# - rcuscale.kfree_nthreads
# - rcuscale.kfree_rcu_test
# - rcuscale.kfree_rcu_test_double
# - rcuscale.kfree_rcu_test_single
# - rcuscale.minruntime
# - rcuscale.nreaders
# - rcuscale.nwriters
# - rcuscale.scale_type
# - rcuscale.shutdown
# - rcuscale.verbose
# - rcuscale.writer_holdoff
# - rcuscale.writer_holdoff_jiffies
# - rcutorture.fqs_duration
# - rcutorture.fqs_holdoff
# - rcutorture.fqs_stutter
# - rcutorture.fwd_progress
# - rcutorture.fwd_progress_div
# - rcutorture.fwd_progress_holdoff
# - rcutorture.fwd_progress_need_resched
# - rcutorture.gp_cond
# - rcutorture.gp_exp
# - rcutorture.gp_normal
# - rcutorture.gp_sync
# - rcutorture.irqreader
# - rcutorture.leakpointer
# - rcutorture.n_barrier_cbs
# - rcutorture.nfakewriters
# - rcutorture.nocbs_nthreads
# - rcutorture.nocbs_toggle
# - rcutorture.nreaders
# - rcutorture.object_debug
# - rcutorture.onoff_holdoff
# - rcutorture.onoff_interval
# - rcutorture.read_exit
# - rcutorture.read_exit_burst
# - rcutorture.read_exit_delay
# - rcutorture.shuffle_interval
# - rcutorture.shutdown_secs
# - rcutorture.stall_cpu
# - rcutorture.stall_cpu_block
# - rcutorture.stall_cpu_holdoff
# - rcutorture.stall_cpu_irqsoff
# - rcutorture.stall_cpu_repeat
# - rcutorture.stall_gp_kthread
# - rcutorture.stat_interval
# - rcutorture.stutter
# - rcutorture.test_boost
# - rcutorture.test_boost_duration
# - rcutorture.test_boost_interval
# - rcutorture.test_no_idle_hz
# - rcutorture.torture_type
# - rcutorture.verbose
# - rcutree.blimit
# - rcutree.csd_lock_suppress_rcu_stall
# - rcutree.do_rcu_barrier
# - rcutree.dump_tree
# - rcutree.enable_rcu_lazy
# - rcutree.gp_cleanup_delay
# - rcutree.gp_init_delay
# - rcutree.gp_preinit_delay
# - rcutree.jiffies_till_first_fqs
# - rcutree.jiffies_till_next_fqs
# - rcutree.jiffies_till_sched_qs
# - rcutree.kthread_prio
# - rcutree.nocb_nobypass_lim_per_jiffy
# - rcutree.nohz_full_patience_delay
# - rcutree.qhimark
# - rcutree.qlowmark
# - rcutree.qovld
# - rcutree.rcu_delay_page_cache_fill_msec
# - rcutree.rcu_divisor
# - rcutree.rcu_fanout_exact
# - rcutree.rcu_fanout_leaf
# - rcutree.rcu_kick_kthreads
# - rcutree.rcu_min_cached_objs
# - rcutree.rcu_nocb_gp_stride
# - rcutree.rcu_normal_wake_from_gp
# - rcutree.rcu_resched_ns
# - rcutree.rcu_unlock_delay
# - rcutree.sysrq_rcu
# - rcutree.use_softirq
# - rdinit
# - rdrand
# - rdt
# - reboot
# - refscale.holdoff
# - refscale.lookup_instances
# - refscale.loops
# - refscale.nreaders
# - refscale.nruns
# - refscale.readdelay
# - refscale.scale_type
# - refscale.shutdown
# - refscale.verbose
# - refscale.verbose_batched
# - reg_file_data_sampling
# - relax_domain_level
# - reserve
# - reserve_mem
# - reservetop
# - resume
# - resumedelay
# - resume_offset
# - retbleed
# - rfkill.default_state
# - rfkill.master_switch_mode
# - ring3mwait
# - rodata
# - root
# - rootdelay
# - rootflags
# - rootfstype
# - rootwait
# - rproc_mem
# - s390_iommu
# - s390_iommu_aperture
# - scftorture.holdoff
# - scftorture.longwait
# - scftorture.nthreads
# - scftorture.onoff_holdoff
# - scftorture.onoff_interval
# - scftorture.shutdown_secs
# - scftorture.stat_interval
# - scftorture.stutter_cpus
# - scftorture.use_cpus_read_lock
# - scftorture.verbose
# - scftorture.weight_all
# - scftorture.weight_all_wait
# - scftorture.weight_many
# - scftorture.weight_many_wait
# - scftorture.weight_single
# - scftorture.weight_single_wait
# - schedstats
# - sched_thermal_decay_shift
# - security
# - selinux
# - sev
# - shapers
# - show_lapic
# - skew_tick
# - slab_max_order
# - slab_min_objects
# - slab_min_order
# - slram
# - smart2
# - smp.csd_lock_timeout
# - smp.panic_on_ipistall
# - smsc-ircc2.ircc_cfg
# - smsc-ircc2.ircc_dma
# - smsc-ircc2.ircc_fir
# - smsc-ircc2.ircc_irq
# - smsc-ircc2.ircc_sir
# - smsc-ircc2.ircc_transceiver
# - smt
# - softlockup_all_cpu_backtrace
# - softlockup_panic
# - spec_rstack_overflow
# - spec_store_bypass_disable
# - spectre_bhi
# - spectre_v2
# - spectre_v2_user
# - split_lock_detect
# - srbds
# - ssbd
# - stack_depot_disable
# - stack_guard_gap
# - stacktrace_filter
# - sti
# - stifb
# - sti_font
# - sunrpc.max_resvport
# - sunrpc.min_resvport
# - sunrpc.pool_mode
# - sunrpc.svc_rpc_per_connection_limit
# - sunrpc.tcp_slot_table_entries
# - sunrpc.udp_slot_table_entries
# - suspend.pm_test_delay
# - svm
# - swiotlb
# - switches
# - tcpmhash_entries
# - tdfx
# - test_suspend
# - thash_entries
# - thermal.act
# - thermal.crt
# - thermal.off
# - thermal.psv
# - thermal.tzp
# - thp_anon
# - topology
# - torture.disable_onoff_at_boot
# - torture.ftrace_dump_at_shutdown
# - torture.verbose_sleep_duration
# - torture.verbose_sleep_frequency
# - tpm_suspend_pcr
# - tpm_tis.interrupts
# - trace_buf_size
# - trace_clock
# - trace_event
# - trace_instance
# - trace_options
# - trace_trigger
# - transparent_hugepage
# - trusted.rng
# - trusted.source
# - tsc
# - tsc_early_khz
# - tsx
# - tsx_async_abort
# - uhash_entries
# - uhci-hcd.ignore_oc
# - usbcore.authorized_default
# - usbcore.autosuspend
# - usbcore.blinkenlights
# - usbcore.initial_descriptor_timeout
# - usbcore.old_scheme_first
# - usbcore.quirks
# - usbcore.usbfs_memory_mb
# - usbcore.usbfs_snoop
# - usbcore.usbfs_snoop_max
# - usbcore.use_both_schemes
# - usbhid.jspoll
# - usbhid.kbpoll
# - usbhid.mousepoll
# - usb-storage.delay_use
# - usb-storage.quirks
# - user_debug
# - userpte
# - vdso
# - vdso32
# - vga
# - video
# - video.brightness_switch_enabled
# - virtio_mmio.device
# - vmalloc
# - vmcp_cma
# - vmhalt
# - vmpanic
# - vmpoff
# - vsyscall
# - vt.color
# - vt.cur_default
# - vt.default_blu
# - vt.default_grn
# - vt.default_red
# - vt.default_utf8
# - vt.global_cursor_default
# - vt.italic
# - vt.underline
# - watchdog_thresh
# - workqueue.cpu_intensive_thresh_us
# - workqueue.cpu_intensive_warning_thresh
# - workqueue.panic_on_stall
# - workqueue.unbound_cpus
# - workqueue.watchdog_thresh
# - writecombine
# - xen.balloon_boot_timeout
# - xen_emul_unplug
# - xen.event_eoi_delay
# - xen.event_loop_timeout
# - xen.fifo_events
# - xen_msr_safe
# - xen_scrub_pages
# - xen_timer_slop
# - xirc2ps_cs
# - xive
# - xive.store-eoi
# END ENVIRONMENT VARIABLES

# Kernel boot parameters that will impact performance/power
cmdline=" $(cat /proc/cmdline) "

check_param()
{
	param=$1
	eval value="\${$param-null_boot_param}"
	if [ "$value" != "null_boot_param" ]; then
		param_str="${param#*_}"
		[ -n "$value" ] && param_str="$param_str=$value"
		if ! echo "$cmdline" | grep -qF " $param_str "; then
			echo "Missing parameter: $param_str, actual command line:$cmdline"
			exit 1
		fi
	fi
}

check_param "bp_memmap"
check_param "bp1_memmap"
check_param "bp2_memmap"
check_param "bp3_memmap"
check_param "bp4_memmap"
check_param "bp_disable_mtrr_trim"
check_param "bp_idle"
check_param "bp_maxcpus"
check_param "bp_intel_iommu"
